package main

import (
	"context"
	"google.golang.org/grpc"
	"log"
	"time"
	pb "xiaohuasheng.cc/user/hello/grpc/pubsub/pubsubservice"
)

func main() {
	conn, err := grpc.Dial("localhost:1234", grpc.WithInsecure())
	if err != nil {
		log.Fatal(err)
	}
	defer conn.Close()

	client := pb.NewPubsubServiceClient(conn)

	for {
		_, err = client.Publish(context.Background(), &pb.String{Value: "golang: hello Go"})
		if err != nil {
			log.Fatal(err)
		}
		_, err = client.Publish(context.Background(), &pb.String{Value: "docker: hello Docker"})
		if err != nil {
			log.Fatal(err)
		}
		time.Sleep(time.Second)
	}
}
